home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / comobj.lisp / part02 < prev    next >
Encoding:
Text File  |  1987-07-30  |  57.3 KB  |  1,921 lines

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i076:  Common Objects, Common Loops, Common Lisp, Part02/13
  5. Message-ID: <743@uunet.UU.NET>
  6. Date: 31 Jul 87 19:58:13 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 1910
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: Roy D'Souza <dsouza%hplabsc@hplabs.HP.COM>
  12. Posting-number: Volume 10, Issue 76
  13. Archive-name: comobj.lisp/Part02
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 2 (of 13)."
  22. # Contents:  3600-low.l co-macros.l co-prof.l co-sfun.l co-test.l
  23. #   dfun-templ.l pcl-patches.l xerox-low.l
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f '3600-low.l' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'3600-low.l'\"
  27. else
  28. echo shar: Extracting \"'3600-low.l'\" \(8740 characters\)
  29. sed "s/^X//" >'3600-low.l' <<'END_OF_FILE'
  30. X;;; -*- Mode:LISP; Package:(PCL Lisp 1000); Base:10.; Syntax:Common-lisp; Patch-File: Yes -*-
  31. X;;;
  32. X;;; *************************************************************************
  33. X;;; Copyright (c) 1985 Xerox Corporation.  All rights reserved.
  34. X;;;
  35. X;;; Use and copying of this software and preparation of derivative works
  36. X;;; based upon this software are permitted.  Any distribution of this
  37. X;;; software or derivative works must comply with all applicable United
  38. X;;; States export control laws.
  39. X;;; 
  40. X;;; This software is made available AS IS, and Xerox Corporation makes no
  41. X;;; warranty about the software, its performance or its conformity to any
  42. X;;; specification.
  43. X;;; 
  44. X;;; Any person obtaining a copy of this software is requested to send their
  45. X;;; name and post office or electronic mail address to:
  46. X;;;   CommonLoops Coordinator
  47. X;;;   Xerox Artifical Intelligence Systems
  48. X;;;   2400 Hanover St.
  49. X;;;   Palo Alto, CA 94303
  50. X;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
  51. X;;;
  52. X;;; Suggestions, comments and requests for improvements are also welcome.
  53. X;;; *************************************************************************
  54. X;;;
  55. X;;; This is the 3600 version of the file portable-low.
  56. X;;;
  57. X
  58. X(in-package 'pcl)
  59. X
  60. X(defmacro without-interrupts (&body body)
  61. X  `(zl:without-interrupts ,.body))
  62. X
  63. X  ;;   
  64. X;;;;;; Load Time Constants
  65. X  ;;
  66. X;;;
  67. X;;; This implementation of load-time-eval exploits the perhaps questionable
  68. X;;; feature that it is possible to define optimizers on macros.
  69. X;;; 
  70. X;;;   WHEN                       EXPANDS-TO
  71. X;;;   compile to a file          (#:EVAL-AT-LOAD-TIME-MARKER . <form>)
  72. X;;;   compile to core            '<result of evaluating form>
  73. X;;;   not in compiler at all     (progn <form>)
  74. X;;;
  75. X(defmacro load-time-eval (form)
  76. X  ;; The interpreted definition of load-time-eval.  This definition
  77. X  ;; never gets compiled.
  78. X  (let ((value (gensym)))
  79. X    `(multiple-value-bind (,value)
  80. X     (progn ,form)
  81. X       ,value)))
  82. X
  83. X(compiler:deftransformer (load-time-eval compile-load-time-eval)
  84. X             (form &optional interpreted-form)
  85. X  (ignore interpreted-form)
  86. X  ;; When compiling a call to load-time-eval the compiler will call
  87. X  ;; this optimizer before the macro expansion.
  88. X  (if zl:compiler:(and (boundp '*compile-function*) ;Probably don't need
  89. X                            ;this boundp check
  90. X                            ;but it can't hurt.
  91. X               (funcall *compile-function* :to-core-p))
  92. X      ;; Compiling to core.
  93. X      ;; Evaluate the form now, and expand into a constant
  94. X      ;; (the result of evaluating the form).
  95. X      `',(eval (cadr form))
  96. X      ;; Compiling to a file.
  97. X      ;; Generate the magic which causes the dumper compiler and loader
  98. X      ;; to do magic and evaluate the form at load time.
  99. X      `',(cons compiler:eval-at-load-time-marker (cadr form))))
  100. X
  101. X  ;;   
  102. X;;;;;; Memory Block primitives.
  103. X  ;;   
  104. X
  105. X
  106. X(defmacro make-memory-block (size &optional area)
  107. X  `(make-array ,size :area ,area))
  108. X
  109. X(defmacro memory-block-ref (block offset)    ;Don't want to go faster yet.
  110. X  `(aref ,block ,offset))
  111. X
  112. X(defvar class-wrapper-area)
  113. X(eval-when (load eval)
  114. X  (si:make-area :name 'class-wrapper-area
  115. X        :room t
  116. X        :gc :static))
  117. X
  118. X
  119. X;;;
  120. X;;; Reimplementation OF %INSTANCE
  121. X;;;
  122. X;;; We take advantage of the fact that Symbolics defstruct doesn't depend on
  123. X;;; the fact that Common Lisp defstructs are fixed length.  This allows us to
  124. X;;; use defstruct to define a new type, but use internal structure allocation
  125. X;;; code to make structure of that type of any length we like.
  126. X;;;
  127. X;;; In Symbolics Common Lisp, structures are really just arrays with a magic
  128. X;;; bit set.  The first element of the array points to the symbol which is
  129. X;;; the name of this structure.  The remaining elements are used for the
  130. X;;; slots of the structure.
  131. X;;;
  132. X;;; In our %instance datatype, the array look like
  133. X;;;
  134. X;;;  element 0:  The symbol %INSTANCE, this tells the system what kind of
  135. X;;;              structure this is.
  136. X;;;  element 1:  The meta-class of this %INSTANCE
  137. X;;;  element 2:  This is used to store the value of %instance-ref slot 0.
  138. X;;;  element 3:  This is used to store the value of %instance-ref slot 1.
  139. X;;;     .                                .
  140. X;;;     .                                .
  141. X;;;
  142. X(defstruct (%instance (:print-function print-instance)
  143. X              (:constructor nil)
  144. X              (:predicate %instancep))
  145. X  meta-class)
  146. X
  147. X(zl:defselect ((:property %instance zl:named-structure-invoke))
  148. X  (:print-self (iwmc-class stream print-depth *print-escape*)
  149. X           (print-instance iwmc-class stream print-depth))
  150. X  (:describe   (iwmc-class &optional no-complaints)
  151. X           (ignore no-complaints)
  152. X           (describe-instance iwmc-class)))
  153. X
  154. X(defmacro %make-instance (meta-class size)
  155. X  (let ((instance-var (gensym)))
  156. X    `(let ((,instance-var (make-array (+ 2 ,size))))
  157. X       (setf (SI:ARRAY-NAMED-STRUCTURE-BIT ,instance-var) 1
  158. X         (aref ,instance-var 0) '%instance
  159. X         (aref ,instance-var 1) ,meta-class)
  160. X       ,instance-var)))
  161. X
  162. X(defmacro %instance-ref (instance index)
  163. X  `(aref ,instance (+ ,index 2)))
  164. X
  165. X  ;;   
  166. X;;;;;; Cache No's
  167. X  ;;  
  168. X
  169. X(zl:defsubst symbol-cache-no (symbol mask)
  170. X  (logand (si:%pointer symbol) mask))            
  171. X
  172. X(compiler:defoptimizer (symbol-cache-no fold-symbol-cache-no) (form)
  173. X  (if (and (constantp (cadr form))                            
  174. X       (constantp (caddr form)))
  175. X      `(load-time-eval (logand (si:%pointer ,(cadr form)) ,(caddr form)))
  176. X      form))
  177. X
  178. X(defmacro object-cache-no (object mask)
  179. X  `(logand (si:%pointer ,object) ,mask))
  180. X
  181. X  ;;   
  182. X;;;;;; printing-random-thing-internal
  183. X  ;;
  184. X(defun printing-random-thing-internal (thing stream)
  185. X  (format stream "~O" (si:%pointer thing)))
  186. X
  187. X  ;;   
  188. X;;;;;; function-arglist
  189. X  ;;
  190. X;;;
  191. X;;; This is hard, I am sweating.
  192. X;;; 
  193. X(defun function-arglist (function) (zl:arglist function t))
  194. X
  195. X(defun function-pretty-arglist (function) (zl:arglist function))
  196. X
  197. X;; Unfortunately, this doesn't really work...
  198. X(defun set-function-pretty-arglist (function new-value)
  199. X  (ignore function new-value))
  200. X
  201. X;; But this does...
  202. X(zl:advise zl:arglist
  203. X       :after
  204. X       pcl-patch-to-arglist
  205. X       ()
  206. X  (let ((function (car zl:arglist))
  207. X    (discriminator nil))
  208. X      (when (and (symbolp function)
  209. X         (setq discriminator (discriminator-named function)))
  210. X    (setq values (list (discriminator-pretty-arglist discriminator))))))
  211. X
  212. X
  213. X  ;;   
  214. X;;;;;; 
  215. X  ;;   
  216. X
  217. X(defun record-definition (name type &rest args)
  218. X  (case type
  219. X    (method (si:record-source-file-name name 'zl:defun t))
  220. X    (class ())))
  221. X
  222. X(defun compile-time-define (type name &rest ignore)
  223. X  (case type
  224. X    (defun (compiler:file-declare name 'zl:def 'zl:ignore))))
  225. X
  226. X  ;;   
  227. X;;;;;; Environment support and Bug-Fixes
  228. X  ;;
  229. X;;; Some VERY basic environment support for the 3600, and some bug fixes and
  230. X;;; improvements to 3600 system utilities.  These may need some work before
  231. X;;; they will work in release 7.
  232. X;;; 
  233. X(eval-when (load eval)
  234. X  (setf
  235. X    (get 'defmeth 'zwei:definition-function-spec-type) 'defun
  236. X   ;(get 'defmeth 'zwei:definition-function-spec-finder-template) '(0 1)
  237. X    (get 'ndefstruct 'zwei:definition-type-name) "Class"
  238. X    (get 'ndefstruct 'zwei:definition-function-spec-finder-template) '(0 1))
  239. X  )
  240. X
  241. X;;; These changes let me dump instances of PCL metaclasses in files, and also arrange
  242. X;;; for the #S syntax to work for PCL instances.
  243. X;;; si:dump-object and si:get-defstruct-constructor-macro-name get "advised".
  244. X;;; Actually the advice is done by hand since it doesn't get compiled otherwise.
  245. X
  246. X(defvar *old-dump-object*)
  247. X(defun patched-dump-object (object stream)
  248. X  (if (or (si:send si:*bin-dump-table* :get-hash object)
  249. X      (not (and (%instancep object)
  250. X            (class-standard-constructor (class-of object)))))
  251. X      (funcall *old-dump-object* object stream)
  252. X      ;; Code pratically copied from dump-instance.
  253. X      (let ((index (si:enter-table object stream t t)))
  254. X    (si:dump-form-to-eval
  255. X      (cons (class-standard-constructor (class-of object))
  256. X        (iterate
  257. X          ((slot in (all-slots object) by cddr)
  258. X           (val in (cdr (all-slots object)) by cddr))
  259. X          (collect (make-keyword slot))
  260. X          (collect `',val)))
  261. X      stream)
  262. X    (si:finish-enter-table object index))))
  263. X
  264. X(unless (boundp '*old-dump-object*)
  265. X  (setf *old-dump-object* (symbol-function 'si:dump-object)
  266. X    (symbol-function 'si:dump-object) 'patched-dump-object))
  267. X
  268. X(defvar *old-get-defstruct-constructor-macro-name*)
  269. X(defun patched-get-defstruct-constructor-macro-name (structure)
  270. X  (let ((class (class-named structure t)))
  271. X    (if class
  272. X    (class-standard-constructor class)
  273. X    (funcall *old-get-defstruct-constructor-macro-name* structure))))
  274. X
  275. X
  276. X(unless (boundp '*old-get-defstruct-constructor-macro-name*)
  277. X  (setf *old-get-defstruct-constructor-macro-name*
  278. X       (symbol-function 'si:get-defstruct-constructor-macro-name)
  279. X    (symbol-function 'si:get-defstruct-constructor-macro-name)
  280. X       'patched-get-defstruct-constructor-macro-name))
  281. X
  282. END_OF_FILE
  283. if test 8740 -ne `wc -c <'3600-low.l'`; then
  284.     echo shar: \"'3600-low.l'\" unpacked with wrong size!
  285. fi
  286. # end of '3600-low.l'
  287. fi
  288. if test -f 'co-macros.l' -a "${1}" != "-c" ; then 
  289.   echo shar: Will not clobber existing file \"'co-macros.l'\"
  290. else
  291. echo shar: Extracting \"'co-macros.l'\" \(7103 characters\)
  292. sed "s/^X//" >'co-macros.l' <<'END_OF_FILE'
  293. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  294. X;
  295. X; File:         co-macros.l
  296. X; RCS:          $Revision: 1.1 $
  297. X; SCCS:         %A% %G% %U%
  298. X; Description:  Macros used by Interface For CommonObjects
  299. X;               with co parser in CL.
  300. X; Author:       James Kempf, HP/DCC
  301. X; Created:      31-Jul-86
  302. X; Modified:     11-Mar-87 22:22:44 (James Kempf)
  303. X; Language:     Lisp
  304. X; Package:      COMMON-OBJECTS
  305. X; Status:       Distribution
  306. X;
  307. X; (c) Copyright 1987, HP Labs, all rights reserved.
  308. X;
  309. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  310. X;
  311. X; Copyright (c) 1987 Hewlett-Packard Corporation. All rights reserved.
  312. X;
  313. X; Use and copying of this software and preparation of derivative works based
  314. X; upon this software are permitted.  Any distribution of this software or
  315. X; derivative works must comply with all applicable United States export
  316. X; control laws.
  317. X; 
  318. X; This software is made available AS IS, and Hewlett-Packard Corporation makes
  319. X; no warranty about the software, its performance or its conformity to any
  320. X; specification.
  321. X;
  322. X; Suggestions, comments and requests for improvement may be mailed to
  323. X; aiws@hplabs.HP.COM
  324. X
  325. X;;;-*-Mode:LISP; Package:(CO (PCL LISP)); Base:10; Syntax: Common-lisp-*-
  326. X;;;
  327. X;;; *************************************************************************
  328. X;;; Copyright (c) 1985 Xerox Corporation.  All rights reserved.
  329. X;;;
  330. X;;; Use and copying of this software and preparation of derivative works
  331. X;;; based upon this software are permitted.  Any distribution of this
  332. X;;; software or derivative works must comply with all applicable United
  333. X;;; States export control laws.
  334. X;;; 
  335. X;;; This software is made available AS IS, and Xerox Corporation makes no
  336. X;;; warranty about the software, its performance or its conformity to any
  337. X;;; specification.
  338. X;;; 
  339. X;;; Any person obtaining a copy of this software is requested to send their
  340. X;;; name and post office or electronic mail address to:
  341. X;;;   CommonLoops Coordinator
  342. X;;;   Xerox Artifical Intelligence Systems
  343. X;;;   2400 Hanover St.
  344. X;;;   Palo Alto, CA 94303
  345. X;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
  346. X;;;
  347. X;;; Suggestions, comments and requests for improvements are also welcome.
  348. X;;; *************************************************************************
  349. X
  350. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  351. X;  Preliminaries
  352. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  353. X
  354. X;;;The CommonObjects interface is in the COMMON-OBJECTS package. We need
  355. X;;;  both PCL and the CommonObjects parser, which is in the 
  356. X;;   COMMON-OBJECTS-PARSER package. Note that PCL is assumed to be
  357. X;;   loaded.
  358. X
  359. X(provide "co-macros")
  360. X
  361. X(in-package 'common-objects :nicknames '(co) :use '(lisp pcl walker))
  362. X
  363. X;;Export these symbols. They are the only ones which clients should see.
  364. X
  365. X(export
  366. X  '(
  367. X    make-instance
  368. X    define-type
  369. X    define-method
  370. X    call-method
  371. X    apply-method
  372. X    assignedp
  373. X    undefine-type
  374. X    rename-type
  375. X    undef Artifical Intelligence Systems
  376. X;;;   2400 Hanovration-p
  377. X    send?
  378. X    instance
  379. X    import-specialized-functions
  380. X  )
  381. X)
  382. X
  383. X;;Need PCL and patches
  384. X
  385. X(require "pcl")
  386. X(require "pcl-patches")
  387. X
  388. X;;Need the parser
  389. X
  390. X(require "co-parse")
  391. X
  392. X;;Use the parser's package
  393. X
  394. X(use-package 'co-parser)
  395. X
  396. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  397. X;  Constant Definition
  398. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  399. X
  400. X;;;Need this flag to indicate that an instance variable is uninitialized.
  401. X
  402. X(defconstant $UNINITIALIZED-VARIABLE-FLAG 'LISP::*UNDEFINED*)
  403. X
  404. X;;Offsets of important things in instances.
  405. X;;Location of class object.
  406. X
  407. X(defconstant $CLASS-OBJECT-INDEX 0)
  408. X
  409. X;;Location of pointer to self.
  410. X
  411. X(defconstant $SELF-INDEX 1)
  412. X
  413. X;;Starting index of parents.
  414. X
  415. X(defconstant $START-OF-PARENTS 2)
  416. X
  417. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  418. X;  Special Variable Definition
  419. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  420. X
  421. X;;*special-functions-list*-Holds a list of uninterned symbols for TYPE-OF,
  422. X;;  TYPEP, EQL, EQUAL, and EQUALP. These symbols have their function cells
  423. X;;  bound to special functions which use CommonObjects messaging if the
  424. X;;  argument is a CommonObjects object.
  425. X
  426. X(defvar *special-functions-list*
  427. X  (list
  428. X    (cons ':type-of (make-symbol "TYPE-OF"))
  429. X    (cons ':typep (make-symbol "TYPEP"))
  430. X    (cons ':eql (make-symbol "EQL"))
  431. X    (cons ':equal (make-symbol "EQUAL"))
  432. X    (cons ':equalp (make-symbol "EQUALP"))
  433. X  )
  434. X)
  435. X
  436. X;;*universal-methods*-List of universal methods
  437. X
  438. X(defvar *universal-methods*
  439. X  '(
  440. X    :init
  441. X    :initialize
  442. X    :print
  443. X    :describe
  444. X    :eql
  445. X    :equal
  446. X    :equalp
  447. X    :typep
  448. X    :copy
  449. X    :copy-instance
  450. X    :copy-state 
  451. X  )
  452. X)
  453. X
  454. X;;*universal-method-selectors*-List of selectors for universal
  455. X;;  methods
  456. X
  457. X(defvar *universal-method-selectors* NIL)
  458. X
  459. X;;*keyword-standin-package*-Package for interning methods as functions.
  460. X;;  CommonObjects "encourages" the use of keywords as method names,
  461. X;;  but not all CL's allow keyword symbol function cells to be
  462. X;;  occupied.
  463. X
  464. X(eval-when (compile load eval)
  465. X  (defvar *keyword-standin-package* 
  466. X    (or (find-package 'keyword-standin) (make-package 'keyword-standin))
  467. X  )
  468. X)
  469. X
  470. X;;;Unuse the lisp package in the keyword-standin package, to
  471. X;;;  avoid conflicts with named functions.
  472. X
  473. X(unuse-package 'lisp *keyword-standin-package*)
  474. X
  475. X;;*special-method-symbols*-List of special method symbols which 
  476. X;;  shouldn't go into the keyword-standin package, paired with
  477. X;;  their method names.
  478. X
  479. X(defvar *special-method-symbols* 
  480. X  (list
  481. X      (cons ':print 'print-instance)
  482. X  )
  483. X)
  484. X
  485. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  486. X; 
  487. X;    Support for Using Keywords as Method Names
  488. X;
  489. X;  These macros and functions translate keyword method names into
  490. X;  names in a package. Some Common Lisps do allow keyword symbols
  491. X;  to have an associated function, others don't. Rather than
  492. X;  differentiating, a single package, KEYWORD-STANDIN, is used
  493. X;  for method symbols which are keywords.
  494. X;
  495. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  496. X
  497. X;;special-keyword-p-Return T if the keyword is a special method
  498. X;;  symbol.
  499. X
  500. X(defmacro special-keyword-p (keyword)
  501. X  `(assoc ,keyword *special-method-symbols* :test #'eq)
  502. X
  503. X) ;end special-keyword-p
  504. X
  505. X;;keyword-standin-special-Return the special symbol for this
  506. X;;  keyword.
  507. X
  508. X(defmacro keyword-standin-special (keyword)
  509. X  `(cdr (assoc ,keyword *special-method-symbols* :test #'eq))
  510. X
  511. X) ;end keyword-standin-special
  512. X
  513. X;;special-method-p-Return T if the symbol is a special method
  514. X;;  symbol.
  515. X
  516. X(defmacro special-method-p (symbol)
  517. X  `(rassoc ,symbol *special-method-symbols* :test #'eq)
  518. X
  519. X) ;end special-method-p
  520. X
  521. X;;unkeyword-standin-special-Return the keyword for this
  522. X;;  special method
  523. X
  524. X(defmacro unkeyword-standin-special (symbol)
  525. X  `(car (rassoc ,symbol *special-method-symbols* :test #'eq))
  526. X
  527. X) ;end unkeyword-standin-special
  528. X
  529. X;;keyword-standin-Get a standin symbol for a keyword
  530. X
  531. X;;; end of co-macros.l ;;;;;
  532. X
  533. END_OF_FILE
  534. if test 7103 -ne `wc -c <'co-macros.l'`; then
  535.     echo shar: \"'co-macros.l'\" unpacked with wrong size!
  536. fi
  537. # end of 'co-macros.l'
  538. fi
  539. if test -f 'co-prof.l' -a "${1}" != "-c" ; then 
  540.   echo shar: Will not clobber existing file \"'co-prof.l'\"
  541. else
  542. echo shar: Extracting \"'co-prof.l'\" \(5412 characters\)
  543. sed "s/^X//" >'co-prof.l' <<'END_OF_FILE'
  544. X
  545. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  546. X;
  547. X; File:         co-prof.l
  548. X; SCCS:         %A% %G% %U%
  549. X; Description:  Profiling For COOL
  550. X; Author:       James Kempf, HP/DCC
  551. X; Created:      10-Feb-87
  552. X; Modified:     25-Feb-87 10:51:31 (James Kempf)
  553. X; Language:     Lisp
  554. X; Package:      TEST
  555. X;
  556. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  557. X
  558. X(in-package 'test)
  559. X
  560. X(require "co")
  561. X
  562. X(use-package 'co)
  563. X
  564. X(require "co-profmacs")
  565. X
  566. X;;Collection Variable for Test Functions
  567. X
  568. X(defvar *function-symbols* NIL)
  569. X
  570. X;;Default names for output file and output messages.
  571. X;;  Can be overridden before this file is loaded.
  572. X
  573. X(defvar *output-file-name* "runprof.out")
  574. X(defvar *definition-message* "COOL Definition Results")
  575. X(defvar *redefinition-message* "COOL Redefinition Results")
  576. X
  577. X;;Run everything compiled so that best
  578. X;;  times are obtained.
  579. X
  580. X;;Measurement of Type Definition
  581. X
  582. X;;Warmup
  583. X
  584. X(do-type-definition NIL 0 0)
  585. X(compile (first *function-symbols*))
  586. X(funcall (first *function-symbols*))
  587. X
  588. X;;No instance variables and no parents
  589. X
  590. X(do-type-definition T 0 0)
  591. X(compile (first *function-symbols*))
  592. X(funcall (first *function-symbols*))
  593. X
  594. X;;One instance variable and no parents
  595. X
  596. X(do-type-definition T 1 0)
  597. X(compile (first *function-symbols*))
  598. X(funcall (first *function-symbols*))
  599. X
  600. X;;Two instance variables and no parents
  601. X
  602. X(do-type-definition T 2 0)
  603. X(compile (first *function-symbols*))
  604. X(funcall (first *function-symbols*))
  605. X
  606. X;;Three instance variables and no parents
  607. X
  608. X(do-type-definition T 3 0)
  609. X(compile (first *function-symbols*))
  610. X(funcall (first *function-symbols*))
  611. X
  612. X;;No variables and one parent
  613. X
  614. X(do-type-definition T 0 1)
  615. X(compile (first *function-symbols*))
  616. X(funcall (first *function-symbols*))
  617. X
  618. X;;No variables and two parents
  619. X
  620. X(do-type-definition T 0 2)
  621. X(compile (first *function-symbols*))
  622. X(funcall (first *function-symbols*))
  623. X
  624. X;;No variables and three parents
  625. X
  626. X(do-type-definition T 0 3)
  627. X(compile (first *function-symbols*))
  628. X(funcall (first *function-symbols*))
  629. X
  630. X;;Measure Instance Creation
  631. X
  632. X;;Warmup
  633. X
  634. X(do-instance-creation NIL 0 0)
  635. X(compile (first *function-symbols*))
  636. X(funcall (first *function-symbols*))
  637. X
  638. X;;No instance variables and no parents
  639. X
  640. X(do-instance-creation T 0 0)
  641. X(compile (first *function-symbols*))
  642. X(funcall (first *function-symbols*))
  643. X
  644. X;;One instance variable and no parents
  645. X
  646. X(do-instance-creation T 1 0)
  647. X(funcall (first *function-symbols*))
  648. X
  649. X;;Two instance variables and no parents
  650. X
  651. X(do-instance-creation T 2 0)
  652. X(compile (first *function-symbols*))
  653. X(funcall (first *function-symbols*))
  654. X
  655. X;;Three instance variables and no parents
  656. X
  657. X(do-instance-creation T 3 0)
  658. X(compile (first *function-symbols*))
  659. X(funcall (first *function-symbols*))
  660. X
  661. X;;No variables and one parent
  662. X
  663. X(do-instance-creation T 0 1)
  664. X(compile (first *function-symbols*))
  665. X(funcall (first *function-symbols*))
  666. X
  667. X;;No variables and two parents
  668. X
  669. X(do-instance-creation T 0 2)
  670. X(compile (first *function-symbols*))
  671. X(funcall (first *function-symbols*))
  672. X
  673. X;;No variables and three parents
  674. X
  675. X(do-instance-creation T 0 3)
  676. X(compile (first *function-symbols*))
  677. X(funcall (first *function-symbols*))
  678. X
  679. X;;Measurement of Method Definition
  680. X
  681. X(do-method-definition NIL 0 temp1)
  682. X(compile (first *function-symbols*))
  683. X(funcall (first *function-symbols*))
  684. X
  685. X;;So that new symbols will be generated
  686. X
  687. X(setf *list-of-method-symbols* NIL)
  688. X
  689. X;;No predefined method
  690. X
  691. X(do-method-definition T 0 temp1)
  692. X(compile (first *function-symbols*))
  693. X(funcall (first *function-symbols*))
  694. X
  695. X;;Measure method invocation
  696. X
  697. X(do-messaging T 1 temp1)
  698. X(compile (first *function-symbols*))
  699. X(funcall (first *function-symbols*))
  700. X
  701. X;;One predefined method
  702. X
  703. X(do-method-definition T 1 temp2)
  704. X(compile (first *function-symbols*))
  705. X(funcall (first *function-symbols*))
  706. X
  707. X;;Measure method invocation
  708. X
  709. X(do-messaging T 2 temp1 temp2)
  710. X(compile (first *function-symbols*))
  711. X(funcall (first *function-symbols*))
  712. X
  713. X;;Two predefined methods
  714. X
  715. X(do-method-definition T 2 temp3)
  716. X(compile (first *function-symbols*))
  717. X(funcall (first *function-symbols*))
  718. X
  719. X;;Measure method invocation
  720. X
  721. X(do-messaging T 3 temp1 temp2 temp3)
  722. X(compile (first *function-symbols*))
  723. X(funcall (first *function-symbols*))
  724. X
  725. X;;Three predefined methods
  726. X
  727. X(do-method-definition T 3 temp4)
  728. X(compile (first *function-symbols*))
  729. X(funcall (first *function-symbols*))
  730. X
  731. X;;Measure method invocation
  732. X
  733. X(do-messaging T 4 temp1 temp2 temp3 temp4)
  734. X(compile (first *function-symbols*))
  735. X(funcall (first *function-symbols*))
  736. X
  737. X;;Method Invocation and Inheritence
  738. X
  739. X(do-inherited-messaging NIL 0 g0f)
  740. X(compile (first *function-symbols*))
  741. X(funcall (first *function-symbols*))
  742. X
  743. X;;No inheritence
  744. X
  745. X(do-inherited-messaging T 0 g0f)
  746. X(compile (first *function-symbols*))
  747. X(funcall (first *function-symbols*))
  748. X
  749. X
  750. X;;One level
  751. X
  752. X(do-inherited-messaging T 1 g1f)
  753. X(compile (first *function-symbols*))
  754. X(funcall (first *function-symbols*))
  755. X
  756. X
  757. X;;Two levels
  758. X
  759. X(do-inherited-messaging T 2 g2f)
  760. X(compile (first *function-symbols*))
  761. X(funcall (first *function-symbols*))
  762. X
  763. X
  764. X;;Three levels
  765. X
  766. X(do-inherited-messaging T 3 g3f)
  767. X(compile (first *function-symbols*))
  768. X(funcall (first *function-symbols*))
  769. X
  770. X
  771. X;;Dump out the results
  772. X
  773. X(print-results *output-file-name* *definition-message*)
  774. X
  775. X;;Run Everything Again
  776. X
  777. X(dolist (l (reverse *function-symbols*))
  778. X  (funcall l)
  779. X)
  780. X
  781. X;;And dump results
  782. X
  783. X(print-results *output-file-name* *redefinition-message*)
  784. X
  785. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  786. X
  787. X(provide "co-prof")
  788. X
  789. END_OF_FILE
  790. if test 5412 -ne `wc -c <'co-prof.l'`; then
  791.     echo shar: \"'co-prof.l'\" unpacked with wrong size!
  792. fi
  793. # end of 'co-prof.l'
  794. fi
  795. if test -f 'co-sfun.l' -a "${1}" != "-c" ; then 
  796.   echo shar: Will not clobber existing file \"'co-sfun.l'\"
  797. else
  798. echo shar: Extracting \"'co-sfun.l'\" \(5643 characters\)
  799. sed "s/^X//" >'co-sfun.l' <<'END_OF_FILE'
  800. X
  801. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  802. X;
  803. X; File:         co-sfun.l
  804. X; RCS:          $Revision: 1.1 $
  805. X; SCCS:         %A% %G% %U%
  806. X; Description:  Override System Functions
  807. X; Author:       James Kempf
  808. X; Created:      March 10, 1987
  809. X; Modified:     March 10, 1987  13:31:39 (Roy D'Souza)
  810. X; Language:     Lisp
  811. X; Package:      COMMON-OBJECTS
  812. X; Status:       Distribution
  813. X;
  814. X; (c) Copyright 1987, HP Labs, all rights reserved.
  815. X;
  816. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  817. X;
  818. X; Copyright (c) 1987 Hewlett-Packard Corporation. All rights reserved.
  819. X;
  820. X; Use and copying of this software and preparation of derivative works based
  821. X; upon this software are permitted.  Any distribution of this software or
  822. X; derivative works must comply with all applicable United States export
  823. X; control laws.
  824. X; 
  825. X; This software is made available AS IS, and Hewlett-Packard Corporation makes
  826. X; no warranty about the software, its performance or its conformity to any
  827. X; specification.
  828. X;
  829. X; Suggestions, comments and requests for improvement may be mailed to
  830. X; aiws@hplabs.HP.COM
  831. X
  832. X;;;-*-Mode:LISP; Package:(CO (PCL LISP)); Base:10; Syntax: Common-lisp-*-
  833. X;;;
  834. X;;; *************************************************************************
  835. X;;; Copyright (c) 1985 Xerox Corporation.  All rights reserved.
  836. X;;;
  837. X;;; Use and copying of this software and preparation of derivative works
  838. X;;; based upon this software are permitted.  Any distribution of this
  839. X;;; software or derivative works must comply with all applicable United
  840. X;;; States export control laws.
  841. X;;; 
  842. X;;; This software is made available AS IS, and Xerox Corporation makes no
  843. X;;; warranty about the software, its performance or its conformity to any
  844. X;;; specification.
  845. X;;; 
  846. X;;; Any person obtaining a copy of this software is requested to send their
  847. X;;; name and post office or electronic mail address to:
  848. X;;;   CommonLoops Coordinator
  849. X;;;   Xerox Artifical Intelligence Systems
  850. X;;;   2400 Hanover St.
  851. X;;;   Palo Alto, CA 94303
  852. X;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
  853. X;;;
  854. X;;; Suggestions, comments and requests for improvements are also welcome.
  855. X;;; *************************************************************************
  856. X
  857. X(in-package 'common-objects :nicknames '(co) :use '(lisp pcl walker))
  858. X
  859. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  860. X; 
  861. X;    Overridden System Functions
  862. X;
  863. X;  The semantics of CommonObjects requires that the Lisp functions EQL, EQUAL,
  864. X;  EQUALP, and TYPEP go through the corresponding universial methods rather
  865. X;  than having their default behavior, and that TYPE-OF return the CommonObjects
  866. X;  type. To avoid circularity problems, these functions are defined as
  867. X;  special, non-interned symbols, and are SHADOWING-IMPORTED into the
  868. X;  package by the user if this behavior is desired. Note, however,
  869. X;  that the default Lisp symbols can't be specialized because otherwise
  870. X;  circularity problems in PCL functions like CLASS-OF may occur. An application
  871. X;  wanting to use them must call the function IMPORT-SPECIALIZED-FUNCTIONS
  872. X;  (below) to get access.
  873. X;
  874. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  875. X
  876. X(eval-when (load eval)
  877. X
  878. X  (progn
  879. X
  880. X   ;;For TYPE-OF
  881. X
  882. X    (setf 
  883. X      (symbol-function 
  884. X        (cdr (assoc ':type-of *special-functions-list* :test #'eq))
  885. X      )
  886. X      (function (lambda (object) (class-name (class-of object))))
  887. X
  888. X    ) ;setf
  889. X
  890. X   ;;For TYPEP
  891. X
  892. X    (setf 
  893. X      (symbol-function 
  894. X        (cdr (assoc ':typep *special-functions-list* :test #'eq))
  895. X      )
  896. X      (function
  897. X        (lambda (object type) 
  898. X          (cond
  899. X
  900. X            ;;Object is a CommonObjects instance
  901. X
  902. X            ( 
  903. X              (instancep object)
  904. X          (keyword-standin::typep object type)
  905. X            )
  906. X
  907. X            ;;Type is a CommonObjects type
  908. X
  909. X            (
  910. X              (member type (defined-classes))
  911. X              NIL
  912. X            )
  913. X
  914. X            ;;Default
  915. X
  916. X            (
  917. X              T        
  918. X              (lisp::typep object type)
  919. X            )
  920. X
  921. X          ) ;cond 
  922. X        )
  923. X      )
  924. X    ) ;setf
  925. X
  926. X   ;;For EQL
  927. X
  928. X    (setf 
  929. X      (symbol-function 
  930. X        (cdr (assoc ':eql *special-functions-list* :test #'eq))
  931. X      )
  932. X      (function
  933. X        (lambda (object1 object2) 
  934. X          (if (instancep object1)
  935. X        (keyword-standin::eql object1 object2)
  936. X            (lisp::eql object1 object2)
  937. X          )
  938. X        )
  939. X      )
  940. X    ) ;setf
  941. X
  942. X   ;;For EQUAL
  943. X
  944. X    (setf 
  945. X      (symbol-function 
  946. X        (cdr (assoc ':equal *special-functions-list* :test #'eq))
  947. X      )
  948. X      (function
  949. X        (lambda (object1 object2) 
  950. X          (if (instancep object1)
  951. X        (keyword-standin::equal object1 object2)
  952. X            (lisp::equal object1 object2)
  953. X          )
  954. X        )
  955. X      )
  956. X    ) ;setf
  957. X
  958. X   ;;For EQUALP
  959. X
  960. X    (setf 
  961. X      (symbol-function 
  962. X        (cdr (assoc ':equalp *special-functions-list* :test #'eq))
  963. X      )
  964. X      (function
  965. X        (lambda (object1 object2) 
  966. X          (if (instancep object1)
  967. X        (keyword-standin::equalp object1 object2)
  968. X            (lisp::equalp object1 object2)
  969. X          )
  970. X        )
  971. X      )
  972. X    ) ;setf
  973. X
  974. X  ) ;progn
  975. X
  976. X) ;eval-when
  977. X
  978. X;;import-specialized-functions-Import the specialized functions into
  979. X;;  the current package. This will override the Lisp package 
  980. X;;  symbols.
  981. X
  982. X(defmacro import-specialized-functions ()
  983. X
  984. X  (let
  985. X    ( (import-list NIL) )
  986. X
  987. X    `(shadowing-import
  988. X      ',(dolist (p *special-functions-list* import-list)
  989. X         (push (cdr p) import-list)
  990. X       )
  991. X
  992. X      )
  993. X    )
  994. X
  995. X) ;end import-specialized-functions
  996. X
  997. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  998. X
  999. X
  1000. X
  1001. END_OF_FILE
  1002. if test 5643 -ne `wc -c <'co-sfun.l'`; then
  1003.     echo shar: \"'co-sfun.l'\" unpacked with wrong size!
  1004. fi
  1005. # end of 'co-sfun.l'
  1006. fi
  1007. if test -f 'co-test.l' -a "${1}" != "-c" ; then 
  1008.   echo shar: Will not clobber existing file \"'co-test.l'\"
  1009. else
  1010. echo shar: Extracting \"'co-test.l'\" \(6054 characters\)
  1011. sed "s/^X//" >'co-test.l' <<'END_OF_FILE'
  1012. X
  1013. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1014. X;
  1015. X; File:         co-test.l
  1016. X; RCS:          $Revision: 1.1 $
  1017. X; SCCS:         %A% %G% %U%
  1018. X; Description:  Portable Test Macro for Testing COOL
  1019. X; Author:       James Kempf, HP/DCC
  1020. X; Created:      24-Feb-87
  1021. X; Modified:     25-Feb-87 08:45:43 (James Kempf)
  1022. X; Language:     Lisp
  1023. X; Package:      PCL
  1024. X;
  1025. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1026. X;
  1027. X; Copyright (c) 1987 Hewlett-Packard Corporation. All rights reserved.
  1028. X;
  1029. X; Use and copying of this software and preparation of derivative works based
  1030. X; upon this software are permitted.  Any distribution of this software or
  1031. X; derivative works must comply with all applicable United States export
  1032. X; control laws.
  1033. X; 
  1034. X; This software is made available AS IS, and Hewlett-Packard Corporation makes
  1035. X; no warranty about the software, its performance or its conformity to any
  1036. X; specification.
  1037. X;
  1038. X; Suggestions, comments and requests for improvement may be mailed to
  1039. X; aiws@hplabs.HP.COM
  1040. X
  1041. X;;;-*- Mode:LISP; Package: PCL; Base:10; Syntax:Common-lisp -*-
  1042. X;;;
  1043. X;;; *************************************************************************
  1044. X;;; Copyright (c) 1985 Xerox Corporation.  All rights reserved.
  1045. X;;;
  1046. X;;; Use and copying of this software and preparation of derivative works
  1047. X;;; based upon this software are permitted.  Any distribution of this
  1048. X;;; software or derivative works must comply with all applicable United
  1049. X;;; States export control laws.
  1050. X;;; 
  1051. X;;; This software is made available AS IS, and Xerox Corporation makes no
  1052. X;;; warranty about the software, its performance or its conformity to any
  1053. X;;; specification.
  1054. X;;; 
  1055. X;;; Any person obtaining a copy of this software is requested to send their
  1056. X;;; name and post office or electronic mail address to:
  1057. X;;;   CommonLoops Coordinator
  1058. X;;;   Xerox Artifical Intelligence Systems
  1059. X;;;   2400 Hanover St.
  1060. X;;;   Palo Alto, CA 94303
  1061. X;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
  1062. X;;;
  1063. X;;; Suggestions, comments and requests for improvements are also welcome.
  1064. X;;; *************************************************************************
  1065. X;;; 
  1066. X;;; Testing code. Note: This file is derived from the PCL file test.l and
  1067. X;;; removes some of the PCL specific stuff from the test macro.
  1068. X
  1069. X(in-package 'pcl)
  1070. X(use-package 'lisp)
  1071. X
  1072. X(require "pcl")
  1073. X
  1074. X(export
  1075. X  '(
  1076. X    do-test
  1077. X  )
  1078. X)
  1079. X
  1080. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1081. X; 
  1082. X;        Catching Errors
  1083. X;
  1084. X; Since CLtL defines no portable way of catching errors, most system
  1085. X; implementors have done their own. Certainly it would be possible
  1086. X; to code a portable error catcher, but the complexity involved
  1087. X; (catching errors at macroexpand time as well, etc.) is considerable.
  1088. X; As a stopgap, the *WITHOUT-ERRORS* special is provided for people
  1089. X; bringing up COOL on a new system to add their system's special error
  1090. X; catching code. It is taken from the original PCL test file.
  1091. X;
  1092. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1093. X
  1094. X;;Other info needed for exception handling
  1095. X
  1096. X#+HP (require "exception")
  1097. X
  1098. X(defvar *without-errors*
  1099. X    (or #+Symbolics #'(lambda (form)
  1100. X                `(multiple-value-bind (.values. .errorp.)
  1101. X                 (si::errset ,form nil)
  1102. X                   (declare (ignore .values.))
  1103. X                   .errorp.))
  1104. X        #+Xerox     #'(lambda (form)
  1105. X                `(xcl:condition-case (progn ,form nil)
  1106. X                   (error () t)))
  1107. X        
  1108. X            #+HP    #'(lambda (form)
  1109. X                `(extn:when-error 
  1110. X                   (progn ,form NIL)
  1111. X                   T
  1112. X                )
  1113. X            )
  1114. X        nil
  1115. X        )
  1116. X
  1117. X) ;defvar
  1118. X
  1119. X;;without-errors-This macro generates code for error testing
  1120. X
  1121. X(defmacro without-errors (&body body)
  1122. X
  1123. X    (if *without-errors*
  1124. X      (funcall *without-errors* `(progn ,@body))
  1125. X      (error "Calling WITHOUT-ERRORS when *without-errors* is nil.")
  1126. X    )
  1127. X
  1128. X
  1129. X) ;without-errors
  1130. X
  1131. X;;with-return-value-Set up each form in BODY to match return value
  1132. X
  1133. X(defmacro with-return-value (form return-value)
  1134. X
  1135. X  ;;Note the use of full qualification on EQUALP
  1136. X  ;;  to avoid problems with redefinition from CO
  1137. X
  1138. X  `(lisp::equalp ',return-value ,form)
  1139. X
  1140. X) ;with-return-value
  1141. X
  1142. X;;do-test-Execute BODY according to the options list
  1143. X
  1144. X(defmacro do-test (name&options &body body)
  1145. X  (let 
  1146. X    (
  1147. X      (name (if (listp name&options) (car name&options) name&options))
  1148. X      (options (if (listp name&options) (cdr name&options) ()))
  1149. X      (code NIL)
  1150. X    )
  1151. X
  1152. X    ;;Bind the options from keywords
  1153. X  
  1154. X    (keyword-bind 
  1155. X      (
  1156. X        (should-error nil)
  1157. X        (return-value nil)
  1158. X      )
  1159. X
  1160. X      options
  1161. X    
  1162. X      ;;Check if errors should be caught and can be
  1163. X
  1164. X      (cond 
  1165. X
  1166. X        ;;Errors can't be caught in this Lisp, so don't do it
  1167. X
  1168. X        (
  1169. X          (and should-error (null *without-errors*))
  1170. X      `(format t
  1171. X        "~&Skipping testing ~A,~%~
  1172. X         because can't ignore errors in this Common Lisp."
  1173. X         ',name
  1174. X          )
  1175. X        )
  1176. X
  1177. X        ;;Generate code for test. If the return value was supplied
  1178. X        ;;  as an option, check if the return values are the same.
  1179. X        ;;  Note the use of LISP::EQUALP. This is because CommonObjects
  1180. X        ;;  redefines EQUALP.
  1181. X
  1182. X        (t
  1183. X      `(progn
  1184. X        (format t "~&Testing ")
  1185. X        (format t ,name)
  1186. X        (format t "... ")
  1187. X            ,@(dolist (form  body (reverse code))
  1188. X                (push
  1189. X                  `(if
  1190. X             ,(cond
  1191. X            (
  1192. X              should-error
  1193. X              `(without-errors ,form)
  1194. X                        )
  1195. X                        (
  1196. X                          return-value
  1197. X                          `(with-return-value ,@form)
  1198. X                        )
  1199. X                        (
  1200. X                         T
  1201. X                         `(progn ,form)
  1202. X                        )
  1203. X                     )
  1204. X                     (format T "~&OK: ~S~%" ',form)
  1205. X             (format T "~&FAILED: ~S~%" ',form)
  1206. X                  )
  1207. X                  code
  1208. X
  1209. X               ) ;push
  1210. X            ) ;dolist
  1211. X
  1212. X          ) ;progn
  1213. X        )
  1214. X      ) ;cond
  1215. X
  1216. X    ) ;keyword-bind
  1217. X
  1218. X  ) ;let
  1219. X
  1220. X) ;do-test
  1221. X
  1222. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1223. X
  1224. X(provide "co-test")
  1225. X
  1226. END_OF_FILE
  1227. if test 6054 -ne `wc -c <'co-test.l'`; then
  1228.     echo shar: \"'co-test.l'\" unpacked with wrong size!
  1229. fi
  1230. # end of 'co-test.l'
  1231. fi
  1232. if test -f 'dfun-templ.l' -a "${1}" != "-c" ; then 
  1233.   echo shar: Will not clobber existing file \"'dfun-templ.l'\"
  1234. else
  1235. echo shar: Extracting \"'dfun-templ.l'\" \(7420 characters\)
  1236. sed "s/^X//" >'dfun-templ.l' <<'END_OF_FILE'
  1237. X;;;-*-Mode:LISP; Package: PCL; Base:10; Syntax:Common-lisp -*-
  1238. X;;;
  1239. X;;; *************************************************************************
  1240. X;;; Copyright (c) 1985 Xerox Corporation.  All rights reserved.
  1241. X;;;
  1242. X;;; Use and copying of this software and preparation of derivative works
  1243. X;;; based upon this software are permitted.  Any distribution of this
  1244. X;;; software or derivative works must comply with all applicable United
  1245. X;;; States export control laws.
  1246. X;;; 
  1247. X;;; This software is made available AS IS, and Xerox Corporation makes no
  1248. X;;; warranty about the software, its performance or its conformity to any
  1249. X;;; specification.
  1250. X;;; 
  1251. X;;; Any person obtaining a copy of this software is requested to send their
  1252. X;;; name and post office or electronic mail address to:
  1253. X;;;   CommonLoops Coordinator
  1254. X;;;   Xerox Artifical Intelligence Systems
  1255. X;;;   2400 Hanover St.
  1256. X;;;   Palo Alto, CA 94303
  1257. X;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
  1258. X;;;
  1259. X;;; Suggestions, comments and requests for improvements are also welcome.
  1260. X;;; *************************************************************************
  1261. X;;;
  1262. X
  1263. X(in-package 'pcl)
  1264. X
  1265. X
  1266. X;;; 
  1267. X;;; A caching discriminating function looks like:
  1268. X;;;   (lambda (arg-1 arg-2 arg-3 &rest rest-args)
  1269. X;;;     (prog* ((class-1 (class-of arg-1))
  1270. X;;;             (class-2 (class-of arg-2))
  1271. X;;;             method-function)
  1272. X;;;        (and (cached-method method-function CACHE MASK class-1 class-2)
  1273. X;;;             (go hit))
  1274. X;;;      miss
  1275. X;;;        (setq method-function
  1276. X;;;              (cache-method DISCRIMINATOR
  1277. X;;;                            (lookup-method-function DISCRIMINATOR
  1278. X;;;                                                    class-1
  1279. X;;;                                                    class-2)))
  1280. X;;;      hit
  1281. X;;;        (if method-function
  1282. X;;;            (return (apply method-function arg-1 arg-2 arg-3 rest-args))
  1283. X;;;            (return (no-matching-method DISCRIMINATOR)))))
  1284. X;;;
  1285. X;;; The upper-cased variables are the ones which are lexically bound.
  1286. X
  1287. X;;; There is a great deal of room to play here.  This open codes the
  1288. X;;; test to see if the instance is iwmc-class-p.  Only if it isn't is
  1289. X;;; there a function call to class-of.  This is done because we only have
  1290. X;;; a default implementation of make-discriminating-function, we don't
  1291. X;;; have one which is specific to discriminator-class DISCRIMINATOR and
  1292. X;;; meta-class CLASS.
  1293. X;;;
  1294. X;;; Of course a real implementation of CommonLoops wouldn't even do a
  1295. X;;; real function call to get to the discriminating function.
  1296. X
  1297. X(eval-when (compile load eval)
  1298. X
  1299. X(defun default-make-class-of-form-fn (arg)
  1300. X  `(if (iwmc-class-p ,arg)
  1301. X       (class-of--class ,arg)
  1302. X       (class-of ,arg)))
  1303. X
  1304. X(defvar *make-class-of-form-fn* #'default-make-class-of-form-fn)
  1305. X
  1306. X(define-function-template caching-discriminating-function
  1307. X                          (required restp
  1308. X                    specialized-positions
  1309. X                    lookup-function)
  1310. X                          '(.DISCRIMINATOR. .CACHE. .MASK.)
  1311. X  (let* ((args (iterate ((i from 0 below required))
  1312. X                 (collect (make-symbol (format nil "Disc-Fn-Arg ~D" i)))))
  1313. X         (class-bindings
  1314. X           (iterate ((i from 0 below required)
  1315. X                     (ignore in specialized-positions))
  1316. X             (if (member i specialized-positions)
  1317. X                 (collect
  1318. X           (list (make-symbol (format nil "Class of ARG ~D" i))
  1319. X             (funcall *make-class-of-form-fn* (nth i args))))
  1320. X                 (collect nil))))
  1321. X         (classes (remove nil (mapcar #'car class-bindings)))
  1322. X         (method-function-var (make-symbol "Method Function"))
  1323. X         (rest-arg-var (and restp (make-symbol "Disc-Fn-&Rest-Arg"))))
  1324. X    `(function
  1325. X       (lambda (,@args ,@(and rest-arg-var (list '&rest rest-arg-var)))
  1326. X         (prog (,@(remove nil class-bindings) ,method-function-var)
  1327. X       (and (cached-method ,method-function-var .CACHE. .MASK. ,@classes)
  1328. X        (go hit))
  1329. X      ;miss
  1330. X       (setq ,method-function-var
  1331. X         (cache-method .CACHE.
  1332. X                   .MASK.
  1333. X                   (,lookup-function .DISCRIMINATOR.
  1334. X                         ,@(mapcar #'car
  1335. X                               class-bindings))
  1336. X                   ,@classes))
  1337. X       hit
  1338. X       (if ,method-function-var
  1339. X           (return ,(if restp
  1340. X                `(apply ,method-function-var
  1341. X                    ,@args
  1342. X                    ,rest-arg-var)
  1343. X                `(funcall ,method-function-var ,@args)))
  1344. X           (no-matching-method .DISCRIMINATOR.)))))))
  1345. X)
  1346. X
  1347. X(eval-when (compile)
  1348. X(defmacro pre-make-caching-discriminating-functions (specs)
  1349. X  `(progn . ,(iterate ((spec in specs))
  1350. X           (collect `(pre-make-templated-function-constructor
  1351. X               caching-discriminating-function
  1352. X               ,@spec))))))
  1353. X
  1354. X(eval-when (load)
  1355. X  (pre-make-caching-discriminating-functions
  1356. X    ((2 NIL (0 1) LOOKUP-MULTI-METHOD)
  1357. X     (4 NIL (0) LOOKUP-CLASSICAL-METHOD)
  1358. X     (5 NIL (0) LOOKUP-CLASSICAL-METHOD)
  1359. X     (1 T (0) LOOKUP-CLASSICAL-METHOD)
  1360. X     (3 NIL (0 1) LOOKUP-MULTI-METHOD)
  1361. X     (4 T (0) LOOKUP-CLASSICAL-METHOD)
  1362. X     (3 T (0) LOOKUP-CLASSICAL-METHOD)
  1363. X     (3 NIL (0) LOOKUP-CLASSICAL-METHOD)
  1364. X     (1 NIL (0) LOOKUP-CLASSICAL-METHOD)
  1365. X     (2 NIL (0) LOOKUP-CLASSICAL-METHOD))))
  1366. X
  1367. X  ;;   
  1368. X;;;;;; 
  1369. X  ;;
  1370. X
  1371. X(eval-when (compile load eval)
  1372. X
  1373. X(define-function-template checking-discriminating-function
  1374. X    (required restp defaultp checks)
  1375. X    `(discriminator method-function default-function
  1376. X            ,@(make-checking-discriminating-function-1 checks))
  1377. X  (let* ((arglist (make-discriminating-function-arglist required restp)))
  1378. X    `(function
  1379. X       (lambda ,arglist
  1380. X     (declare (optimize (speed 3) (safety 0)))
  1381. X     discriminator default-function ;ignorable
  1382. X         (if (and ,@(iterate ((check in
  1383. X                     (make-checking-discriminating-function-1
  1384. X                       checks))
  1385. X                              (arg in arglist))
  1386. X                      (when (neq check 'ignore)
  1387. X            (collect
  1388. X              `(memq ,check
  1389. X                 (let ((.class. (class-of ,arg)))
  1390. X                   (get-slot--class .class.
  1391. X                            'class-precedence-list)))))))
  1392. X             ,(if restp
  1393. X                  `(apply method-function ,@(remove '&rest arglist))
  1394. X                  `(funcall method-function ,@arglist))
  1395. X             ,(if defaultp
  1396. X                  (if restp
  1397. X                      `(apply default-function ,@(remove '&rest arglist))
  1398. X                      `(funcall default-function ,@arglist))
  1399. X                  `(no-matching-method discriminator)))))))
  1400. X
  1401. X(defun make-checking-discriminating-function-1 (check-positions)
  1402. X  (iterate ((pos in check-positions))
  1403. X    (collect (if (null pos) 'ignore (intern (format nil "Check ~D" pos))))))
  1404. X
  1405. X)
  1406. X
  1407. X(eval-when (compile)
  1408. X(defmacro pre-make-checking-discriminating-functions (specs)
  1409. X  `(progn . ,(iterate ((spec in specs))
  1410. X           (collect `(pre-make-templated-function-constructor
  1411. X               checking-discriminating-function
  1412. X               ,@spec))))))
  1413. X
  1414. X(eval-when (load)
  1415. X  (pre-make-checking-discriminating-functions ((3 NIL NIL (0 1))
  1416. X                           (7 NIL NIL (0 1))
  1417. X                           (5 NIL NIL (0 1))
  1418. X                           (3 NIL NIL (0 NIL 2))
  1419. X                           (6 NIL NIL (0))
  1420. X                           (5 NIL NIL (0))
  1421. X                           (4 T NIL (0))
  1422. X                           (3 T NIL (0))
  1423. X                           (1 T NIL (0))
  1424. X                           (4 NIL NIL (0))
  1425. X                           (3 NIL NIL (0))
  1426. X                           (3 NIL T (0 1))
  1427. X                           (2 NIL T (0))
  1428. X                           (5 NIL T (0 1))
  1429. X                           (1 T T (0))
  1430. X                           (1 NIL T (0))
  1431. X                           (2 NIL T (0 1))
  1432. X                           (3 NIL T (0))
  1433. X                           (2 T T (0))
  1434. X                           (6 NIL T (0 1))
  1435. X                           (3 NIL T (0 NIL 2))
  1436. X                           (4 NIL T (0 1))
  1437. X                           (4 NIL T (0))
  1438. X                           (5 NIL T (0))
  1439. X                           (1 NIL NIL (0))
  1440. X                           (2 NIL NIL (0)))))
  1441. X
  1442. END_OF_FILE
  1443. if test 7420 -ne `wc -c <'dfun-templ.l'`; then
  1444.     echo shar: \"'dfun-templ.l'\" unpacked with wrong size!
  1445. fi
  1446. # end of 'dfun-templ.l'
  1447. fi
  1448. if test -f 'pcl-patches.l' -a "${1}" != "-c" ; then 
  1449.   echo shar: Will not clobber existing file \"'pcl-patches.l'\"
  1450. else
  1451. echo shar: Extracting \"'pcl-patches.l'\" \(6462 characters\)
  1452. sed "s/^X//" >'pcl-patches.l' <<'END_OF_FILE'
  1453. X
  1454. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1455. X;
  1456. X; File:         pcl-patches.l
  1457. X; RCS:          $Revision: 1.1 $
  1458. X; SCCS:         %A% %G% %U%
  1459. X; Description:  Patches to Released PCL so CommonObjects works
  1460. X; Author:       James Kempf, HP/DCC
  1461. X; Created:      11-Nov-86
  1462. X; Modified:     5-Mar-87 08:04:02 (James Kempf)
  1463. X; Language:     Lisp
  1464. X; Package:      PCL
  1465. X; Status:       Distribution
  1466. X;
  1467. X; (c) Copyright 1987, HP Labs, all rights reserved.
  1468. X;
  1469. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1470. X;
  1471. X; Copyright (c) 1987 Hewlett-Packard Corporation. All rights reserved.
  1472. X;
  1473. X; Use and copying of this software and preparation of derivative works based
  1474. X; upon this software are permitted.  Any distribution of this software or
  1475. X; derivative works must comply with all applicable United States export
  1476. X; control laws.
  1477. X; 
  1478. X; This software is made available AS IS, and Hewlett-Packard Corporation makes
  1479. X; no warranty about the software, its performance or its conformity to any
  1480. X; specification.
  1481. X;
  1482. X; Suggestions, comments and requests for improvement may be mailed to
  1483. X; aiws@hplabs.HP.COM
  1484. X
  1485. X;;Need the PCL module
  1486. X
  1487. X(require "pcl")
  1488. X
  1489. X(in-package 'pcl)
  1490. X(use-package 'lisp)
  1491. X
  1492. X;;These symbols are needed by CommonObjects
  1493. X
  1494. X(export
  1495. X  '(
  1496. X    print-instance
  1497. X    make-specializable
  1498. X    rename-class
  1499. X    call-next-method
  1500. X    expand-with-make-entries
  1501. X    method-type-specifiers
  1502. X    method-arglist
  1503. X  )
  1504. X)
  1505. X
  1506. X;;Note-Every implementation of CL will need to add the
  1507. X;;  check for nonatomic type specifiers.
  1508. X
  1509. X#+HP(setq *class-of*
  1510. X    '(lambda (x) 
  1511. X       (cond ((%instancep x)
  1512. X          (%instance-class-of x))
  1513. X         ;; Ports of PCL should define the rest of class-of
  1514. X         ;; more meaningfully.  Because of the underspecification
  1515. X                 ;; of type-of this is the best that I can do.
  1516. X         ((null x)
  1517. X                  (class-named 'null))
  1518. X                 ((stringp x)
  1519. X                  (class-named 'string))
  1520. X         ((characterp x)
  1521. X          (class-named 'character))
  1522. X         (t
  1523. X          (or (class-named (atom-type-of (type-of x)) t)
  1524. X              (error "Can't determine class of ~S." x)
  1525. X          ))
  1526. X            )
  1527. X        )
  1528. X)
  1529. X
  1530. X#+ExCL(eval-when (load)
  1531. X  (setq *class-of*
  1532. X    '(lambda (x) 
  1533. X       (or (and (%instancep x)
  1534. X            (%instance-class-of x))           
  1535. X          ;(%funcallable-instance-p x)
  1536. X           (and (stringp x) (class-named 'string))
  1537. X           (class-named (type-of x) t)
  1538. X           (error "Can't determine class of ~S." x)))
  1539. X  )
  1540. X
  1541. X)
  1542. X
  1543. X;;Now arrange things so CLASS-OF gets recompiled when this file gets
  1544. X;;  loaded
  1545. X
  1546. X#-KCL(eval-when (load eval)
  1547. X
  1548. X  (recompile-class-of)
  1549. X
  1550. X)
  1551. X
  1552. X;;atom-type-of-Return principle type. This is the first
  1553. X;;  item on the type specifier list, or specifier itself,
  1554. X;;  if the specifier is atomic.
  1555. X
  1556. X(defun atom-type-of (x)
  1557. X
  1558. X  (if (listp x)
  1559. X    (car x)
  1560. X    x
  1561. X  )
  1562. X
  1563. X) ;end atom-type-of
  1564. X
  1565. X;;
  1566. X;;
  1567. X;;
  1568. X;;
  1569. X;; Default print-instance method
  1570. X;;
  1571. X;;
  1572. X;;
  1573. X
  1574. X(defmeth print-instance (instance stream depth) 
  1575. X  (printing-random-thing (instance stream)    
  1576. X    (format stream "instance ??")))
  1577. X
  1578. X;;;New for CO
  1579. X
  1580. X
  1581. X;;rename-class-Find the class object named old-name and rename to
  1582. X;;  new-name
  1583. X
  1584. X(defmeth rename-class ((old-name symbol) (new-name symbol))
  1585. X
  1586. X  (rename-class (class-named old-name) new-name)
  1587. X
  1588. X) ;end rename-class
  1589. X
  1590. X
  1591. X;;rename-class-Change the name of the essential class's name to name
  1592. X
  1593. X(defmeth rename-class ((class essential-class) (name symbol))
  1594. X
  1595. X  (let
  1596. X    (
  1597. X      (old-name (class-name class))
  1598. X    )
  1599. X
  1600. X
  1601. X    (setf (class-name class) name)
  1602. X
  1603. X    ;;Needed to be sure the naming hash table is OK
  1604. X
  1605. X    (setf (class-named name) class)
  1606. X    (setf (class-named old-name) NIL)
  1607. X    name
  1608. X  )
  1609. X
  1610. X) ;end rename-class
  1611. X
  1612. X
  1613. X;;
  1614. X;;
  1615. X;;
  1616. X;; From class-prot.l
  1617. X;;
  1618. X;;
  1619. X;;
  1620. X
  1621. X;;JAK 2/15/86 Additional bug. OPTIMIZE-GET-SLOT and OPTIMIZE-SETF-OF
  1622. X;;  GET-SLOT didn't seem to be getting called. This version calls
  1623. X;;  them. NOTE-this has been added to CLASS-PROT.L so that the
  1624. X;;  optimization functions get called in the kernel as well.
  1625. X
  1626. X(defun expand-with-slots
  1627. X       (proto-discriminator proto-method first-arg env body)
  1628. X  (ignore proto-discriminator)
  1629. X  (let ((entries (expand-with-make-entries proto-method first-arg))
  1630. X    (gensyms ()))
  1631. X    (dolist (arg first-arg)
  1632. X      (push (list (if (listp arg) (car arg) arg)
  1633. X          (gensym))
  1634. X        gensyms))
  1635. X    `(let ,(mapcar #'reverse gensyms)
  1636. X       ,(walk-form (cons 'progn body)
  1637. X      :environment env
  1638. X      :walk-function
  1639. X      #'(lambda (form context &aux temp)
  1640. X          (cond ((and (symbolp form)
  1641. X              (eq context ':eval)
  1642. X              (null (variable-lexical-p form))
  1643. X              (null (variable-special-p form))
  1644. X              (setq temp (assq form entries)))
  1645. X             (if (car (cddddr temp))    ;use slot-value?
  1646. X                         (optimize-get-slot 
  1647. X                          ;;;;  proto-method     ;;the method object ;rds 3/8 
  1648. X                           (third temp)        ;;the class object
  1649. X               `(get-slot ,(cadr (assq (cadr temp) gensyms))
  1650. X                    ',(slotd-name (cadddr temp)))
  1651. X                         )
  1652. X             `(,(slotd-accessor (cadddr temp))
  1653. X               ,(cadr (assq (cadr temp) gensyms)))))
  1654. X            ((and (listp form)
  1655. X              (or (eq (car form) 'setq)
  1656. X                  (eq (car form) 'setf)))
  1657. X             (cond ((cdddr form)
  1658. X                (cons 'progn
  1659. X                  (iterate ((pair on (cdr form) by cddr))
  1660. X                    (collect (list (car form)
  1661. X                           (car pair)
  1662. X                           (cadr pair))))))
  1663. X               ((setq temp (assq (cadr form) entries))
  1664. X
  1665. X;;JAK 2/14/87 Bug found. The following IF was not included, causing
  1666. X;;  the second form to always be returned. This caused forms like
  1667. X;;;  (SETF (NIL #:G1234) 5) to be generated, which aren't SETF expandable
  1668. X
  1669. X                 (if (not (slotd-accessor (cadddr temp)))
  1670. X                   (optimize-setf-of-get-slot
  1671. X                    ;;; proto-method  ; rds 3/8
  1672. X                                 (third temp)
  1673. X                     `(setf-of-get-slot
  1674. X                       ,(cadr (assq (cadr temp) gensyms))
  1675. X                       ',(slotd-name (cadddr temp))
  1676. X                       ,(caddr form))
  1677. X                )
  1678. X
  1679. X                   `(setf (,(slotd-accessor (cadddr temp))
  1680. X                    ,(cadr (assq (cadr temp) gensyms)))
  1681. X                   ,(caddr form))))
  1682. X               (t form)))
  1683. X            (t form)))))))
  1684. X
  1685. X;;Default methods for optimize-get-slot and optimize-setf-of-get-slot
  1686. X
  1687. X; rds 3/9 changed arglist to conform to new PCL 
  1688. X; (defmeth optimize-get-slot (method class form)
  1689. X;  form
  1690. X;)
  1691. X(defmeth optimize-get-slot (class form)
  1692. X form
  1693. X )
  1694. X
  1695. X; rds 3/9 changed arglist to conform to new PCL
  1696. X;(defmeth optimize-setf-of-get-slot (method class form)
  1697. X;  form
  1698. X;)
  1699. X(defmeth optimize-setf-of-get-slot (class form)
  1700. X form
  1701. X )
  1702. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1703. X
  1704. X(provide "pcl-patches")
  1705. X
  1706. END_OF_FILE
  1707. if test 6462 -ne `wc -c <'pcl-patches.l'`; then
  1708.     echo shar: \"'pcl-patches.l'\" unpacked with wrong size!
  1709. fi
  1710. # end of 'pcl-patches.l'
  1711. fi
  1712. if test -f 'xerox-low.l' -a "${1}" != "-c" ; then 
  1713.   echo shar: Will not clobber existing file \"'xerox-low.l'\"
  1714. else
  1715. echo shar: Extracting \"'xerox-low.l'\" \(5605 characters\)
  1716. sed "s/^X//" >'xerox-low.l' <<'END_OF_FILE'
  1717. X;;; -*- Mode:LISP; Package:(PCL Lisp 1000); Base:10.; Syntax:Common-lisp -*-
  1718. X;;;
  1719. X;;; *************************************************************************
  1720. X;;; Copyright (c) 1985 Xerox Corporation.  All rights reserved.
  1721. X;;;
  1722. X;;; Use and copying of this software and preparation of derivative works
  1723. X;;; based upon this software are permitted.  Any distribution of this
  1724. X;;; software or derivative works must comply with all applicable United
  1725. X;;; States export control laws.
  1726. X;;; 
  1727. X;;; This software is made available AS IS, and Xerox Corporation makes no
  1728. X;;; warranty about the software, its performance or its conformity to any
  1729. X;;; specification.
  1730. X;;; 
  1731. X;;; Any person obtaining a copy of this software is requested to send their
  1732. X;;; name and post office or electronic mail address to:
  1733. X;;;   CommonLoops Coordinator
  1734. X;;;   Xerox Artifical Intelligence Systems
  1735. X;;;   2400 Hanover St.
  1736. X;;;   Palo Alto, CA 94303
  1737. X;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
  1738. X;;;
  1739. X;;; Suggestions, comments and requests for improvements are also welcome.
  1740. X;;; *************************************************************************
  1741. X;;;
  1742. X;;; This is the 1100 (Xerox version) of the file portable-low.
  1743. X;;;
  1744. X
  1745. X(in-package 'pcl)
  1746. X
  1747. X(defmacro load-time-eval (form)
  1748. X  `(il:LOADTIMECONSTANT ,form))
  1749. X
  1750. X  ;;   
  1751. X;;;;;; Memory block primitives.
  1752. X  ;;
  1753. X
  1754. X; what I have done is to replace all calls to il:\\RPLPTR with a call to
  1755. X; RPLPTR (in the PCL) package.  RPLPTR is a version which does some error
  1756. X; checking and then calls il:\\RPLPTR.  As follows:
  1757. X
  1758. X;(defun rplptr (block index value)
  1759. X;  (if (< index (* (il:\\#blockdatacells block) 2))
  1760. X;      (il:\\rplptr block index value)
  1761. X;      (error "bad args to rplptr")))
  1762. X
  1763. X(defmacro make-memory-block (size &optional area)
  1764. X  `(il:\\allocblock ,size T))
  1765. X
  1766. X(defmacro memory-block-ref (block offset)
  1767. X  `(il:\\GETBASEPTR ,block (* ,offset 2)))
  1768. X
  1769. X(defsetf memory-block-ref (memory-block offset) (new-value)
  1770. X  `(il:\\rplptr ,memory-block (* ,offset 2) ,new-value))
  1771. X
  1772. X(defmacro memory-block-size (block)
  1773. X  ;; this returns the amount of memory allocated for the block --
  1774. X  ;; it may be larger than size passed at creation
  1775. X  `(il:\\#BLOCKDATACELLS ,block))
  1776. X
  1777. X(defmacro CLEAR-memory-block (block start)
  1778. X  (once-only (block)
  1779. X    `(let ((end (* (il:\\#blockdatacells ,block) 2)))
  1780. X       (do ((index (* ,start 2) (+ index 2)))
  1781. X       ((= index end))
  1782. X     (il:\\rplptr ,block index nil)))))
  1783. X
  1784. X  ;;   
  1785. X;;;;;; Static slot storage primitives
  1786. X  ;;   
  1787. X
  1788. X;;;
  1789. X;;; Once everything sees to work, uncomment this back into play and remove
  1790. X;;; the * 2 in the other places.
  1791. X;;; 
  1792. X;(defmacro %convert-slotd-position-to-slot-index (slotd-position)
  1793. X; `(* 2 ,slotd-position))
  1794. X
  1795. X(defmacro %allocate-static-slot-storage--class (no-of-slots)
  1796. X  `(il:\\ALLOCBLOCK ,no-of-slots t))
  1797. X
  1798. X(defmacro %static-slot-storage-get-slot--class (static-slot-storage
  1799. X                        slot-index)
  1800. X  `(il:\\GETBASEPTR ,static-slot-storage (* ,slot-index 2)))
  1801. X
  1802. X(defsetf %static-slot-storage-get-slot--class (static-slot-storage
  1803. X                           slot-index)
  1804. X                          (new-value)
  1805. X  `(il:\\rplptr ,static-slot-storage (* ,slot-index 2) ,new-value))
  1806. X
  1807. X
  1808. X  ;;   
  1809. X;;;;;; Instance With Meta-Class Class (IWMC-CLASS)
  1810. X  ;;   
  1811. X;;; In Xerox Lisp, the type of an object is inextricably linked to its size.
  1812. X;;; This means that we can't build IWMC-CLASS on top of %instance and still
  1813. X;;; get rid of the indirection to instance-storage the way we would like to.
  1814. X;;; So, we build iwmc-class on its own base using defstruct.
  1815. X;;;
  1816. X;;; NOTE: %instance-meta-class will not return the right value for an
  1817. X;;;       instance
  1818. X
  1819. X(eval-when (compile load eval)
  1820. X  ;; see if we can save our implementation of macros from itself
  1821. X  (dolist (x '(iwmc-class-class-wrapper
  1822. X           iwmc-class-static-slots
  1823. X           iwmc-class-dynamic-slots))
  1824. X    (fmakunbound x)
  1825. X    (remprop x 'il:macro-fn)))
  1826. X
  1827. X(defstruct (iwmc-class (:predicate iwmc-class-p)
  1828. X               (:conc-name iwmc-class-)
  1829. X               (:constructor %%allocate-instance--class ())
  1830. X               (:print-function print-instance))
  1831. X  (class-wrapper nil)
  1832. X  (static-slots nil)
  1833. X  (dynamic-slots ()))
  1834. X
  1835. X(defmacro %allocate-instance--class (no-of-slots &optional class-class)
  1836. X  `(let ((iwmc-class (%%allocate-instance--class)))
  1837. X     (%allocate-instance--class-1 ,no-of-slots iwmc-class)
  1838. X     iwmc-class))
  1839. X
  1840. X
  1841. X(defmacro %allocate-class-class (no-of-slots)    ;This is used to allocate the
  1842. X  `(let ((i (%%allocate-instance--class)))    ;class class.  It bootstraps
  1843. X    ;(setf (%instance-meta-class i) i)        ;the call to class-named in
  1844. X     (setf (class-named 'class) i)        ;%allocate-instance--class.
  1845. X     (%allocate-instance--class-1 ,no-of-slots i)
  1846. X     i))
  1847. X
  1848. X(eval-when (compile load eval)
  1849. X  (setq *class-of*
  1850. X    '(lambda (x) 
  1851. X       (or (and (iwmc-class-p x)
  1852. X            (class-of--class x))
  1853. X           (and (%instancep x)
  1854. X            (%instance-class-of x))
  1855. X          ;(%funcallable-instance-p x)
  1856. X           (class-named (type-of x) t)
  1857. X           (error "Can't determine class of ~S" x))))
  1858. X
  1859. X  (setq *meta-classes* (delete (assq 'class *meta-classes*) *meta-classes*)))
  1860. X
  1861. X
  1862. X
  1863. X  ;;   
  1864. X;;;;;; FUNCTION-ARGLIST
  1865. X  ;;
  1866. X
  1867. X(defun function-arglist (x) (il:arglist x))
  1868. X
  1869. X  ;;   
  1870. X;;;;;; Generating CACHE numbers
  1871. X  ;;
  1872. X
  1873. X(defmacro symbol-cache-no (symbol mask)
  1874. X  `(logand (il:llsh (logand #o17777 (il:\\loloc ,symbol)) 2) ,mask))
  1875. X
  1876. X(defmacro object-cache-no (object mask)
  1877. X  `(logand (il:\\loloc ,object) ,mask))
  1878. X
  1879. X
  1880. X  ;;   
  1881. X;;;;;; printing-random-thing-internal
  1882. X  ;;
  1883. X
  1884. X(defun printing-random-thing-internal (thing stream)
  1885. X  (princ (il:\\hiloc thing) stream)
  1886. X  (princ "," stream)
  1887. X  (princ (il:\\loloc thing) stream))
  1888. X
  1889. X(defun record-definition (name type &optional parent-name parent-type)
  1890. X  (declare (ignore type parent-name))
  1891. X  ())
  1892. X
  1893. END_OF_FILE
  1894. if test 5605 -ne `wc -c <'xerox-low.l'`; then
  1895.     echo shar: \"'xerox-low.l'\" unpacked with wrong size!
  1896. fi
  1897. # end of 'xerox-low.l'
  1898. fi
  1899. echo shar: End of archive 2 \(of 13\).
  1900. cp /dev/null ark2isdone
  1901. MISSING=""
  1902. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  1903.     if test ! -f ark${I}isdone ; then
  1904.     MISSING="${MISSING} ${I}"
  1905.     fi
  1906. done
  1907. if test "${MISSING}" = "" ; then
  1908.     echo You have unpacked all 13 archives.
  1909.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1910. else
  1911.     echo You still need to unpack the following archives:
  1912.     echo "        " ${MISSING}
  1913. fi
  1914. ##  End of shell archive.
  1915. exit 0
  1916. -- 
  1917.  
  1918. Rich $alz            "Anger is an energy"
  1919. Cronus Project, BBN Labs    rsalz@bbn.com
  1920. Moderator, comp.sources.unix    sources@uunet.uu.net
  1921.